<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>数组相关操作</title>
</head>
<body>
    <script>
        let arr = [1,2,3,4,5,33,12,2,4,56,77,8]
        // arr.forEach((item,index,arr)=>{
        //     console.log(item,index,arr)
        // })

        // const arr1 = arr.filter( (item)=>item > 10 )
        // console.log(arr1)


        // let arr2 = [11,22,33,44]
        // const mapArr = arr2.map((value,index)=>({index,value}))
        // console.log(mapArr)
        const goods = [{id:1,name:'篮球',number:1}
                        ,{id:2,name:'篮球1',number:4}
                        ,{id:2,name:'篮球3',number:5}]

        const sum = goods.reduce((prev,item)=>prev+item.number,0)
        console.log(sum)

        const people = {
            name:'张三',
            age:18,
            sex:'man'
        }
        let str = JSON.stringify(people);
        console.log("json格式字符串：",str)

        let json = '{"name":"张三","age":18,"sex":"man"}'
        let man = JSON.parse(json)
        console.log("反序列化：",man)
    </script>
</body>
</html>